/*
 * CloudCarlos.java
 *
 * Created on 3 de Julho de 2007, 17:27
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package characters;

import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;

/**
 *
 * @author installuser
 */
public class CloudCarlos extends Sprite{
    
    int DISP_WIDTH;
    int DISP_HEIGHT;
    
    static int WIDTH = 38;
    static int HEIGHT = 27;
    
    static int[] FRAME_SEQUENCE={1};
    
    int X;
    int Y;
    
   
     public  CloudCarlos(int initialX, int initialY, int DISP_WIDTH, int DISP_HEIGHT) throws Exception{
        super(Image.createImage("/characters/images/cloud.png"), WIDTH, HEIGHT);
        
        X = initialX;
        Y = initialY;
        this.DISP_WIDTH = DISP_WIDTH;
        this.DISP_HEIGHT = DISP_HEIGHT;

        defineReferencePixel(0, 0);
        setRefPixelPosition(X, Y);
        //setFrameSequence(FRAME_SEQUENCE);
    }
     
      public void execute(){
         if(isOnScreen()){
             goRight();
             setRefPixelPosition(X, Y);
         }else{
             if(X <= 0){
                 System.out.println("carlos");
                 goRight();
             }else{
                 setRefPixelPosition(0, DISP_HEIGHT/3);
             }                         
         }  
    }
    
    public int goRight() {
        return X++;
    }
    
    public boolean isOnScreen(){
        if(X < DISP_WIDTH){
            return true;
        }else{
            return false;
        }
    }
    
   

}
